<template>
  <div class="register-content">
    <div class="title" style="padding-top: 0px;">
      <p> </p>
    </div>
    <div class="form weui-cells weui-cells_form" style="margin-top: 0;">

      <div class="weui-panel weui-panel_access">
        <div class="weui-panel__bd">
          <a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
            <div class="weui-media-box__hd">
              <img class="weui-media-box__thumb" :src="mbInfo.portrait" alt="">
            </div>
            <div class="weui-media-box__bd" style="margin-left: .667rem;">
              <h4 class="weui-media-box__title">{{mbInfo.username}}</h4>
            </div>
          </a>
        </div>
      </div>

      <div class="form weui-cells weui-cells_form">

        <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">性别</label></div>
          <div class="weui-cell__bd">
            <input class="weui-input" type="text" pattern="[0-9]*" placeholder=""
                   value="男" v-if="mbInfo.gender = 1"/>
            <input class="weui-input" type="text" pattern="[0-9]*" placeholder=""
                   value="女" v-else/>
          </div>
        </div>

      </div>

      <div class="form weui-cells weui-cells_form">
        <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">生日</label></div>
          <div class="weui-cell__bd">
            <input class="weui-input" type="text" pattern="[0-9]*" :value="mbInfo.birthday"/>
          </div>
        </div>
      </div>

      <div class="form weui-cells weui-cells_form">
        <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">手机号</label></div>
          <div class="weui-cell__bd">
            <input class="weui-input" type="text" pattern="[0-9]*" placeholder="请输入手机号" :value="mbInfo.mobile"/>
          </div>
        </div>
      </div>

    </div>


    <div class="button-sp-area" style="margin-top: 1.173rem;">
      <a href="javascript:history.back();" class="register weui-btn weui-btn_plain-primary">返回</a>
    </div>


    <div id="dialog1" style="display: none;">
      <div class="weui-mask"></div>
      <div class="weui-dialog weui-skin_android">
        <div class="weui-dialog__hd"><strong class="weui-dialog__title" style="font-size: .54rem;color: #333">提示</strong>
        </div>
        <div class="weui-dialog__bd" style="font-size: .427rem; color: #666">该手机号未注册，请先注册会员</div>
        <div class="weui-dialog__ft">
          <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default">取消</a>
          <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary" style="color: #ff6600">注册会员</a>
        </div>
      </div>
    </div>

    <loading :show="showLoading" :text="showLoadingText"></loading>
    <toast v-model="showToast" width="5rem" :type="toastType" :time="800" :text="toastText"></toast>

  </div>
</template>
<script>

  import {Scroller, Loading, Toast} from 'vux'

  import {utils} from './../common/utils/utils'
  import {oauth} from './../common/utils/oauth'
  const common = require('./../common/utils/common')

  export default {
    components: {
      Loading,
      Toast
    },
    data() {
      return {
        mchCodeByUrl: common.getUrlParam('mchCode'),
        openidByUrl: common.getUrlParam('openid'),
        cacheMchCode: localStorage.getItem('mchCode'),
        cacheMchType: localStorage.getItem('type'),
        openid: localStorage.getItem('openid'),

        mbInfo: [],

        showMask: false,
        showLoading: false,
        showLoadingText: '',
        showToast: false,
        toastType: 'cancel',
        toastText: '',

      }
    },
    beforeCreate() {
      document.title = '我的资料'
    },
    async created() {

      this.showLoading = true
      const _this = this

      //授权
      oauth.checkOauth(utils, _this)

      const result = await utils.mbInfo(this.openid, this.cacheMchCode, _this)

      if(result.code === 200) {
        this.showLoading = false
        this.mbInfo = result.values
      }
    },
    methods: {
    }
  }
</script>
<style scoped>
  @import "./../assets/css/register.css";
  @import "~weui";
  .register-content .form{
    margin-top: 0px;
  }
</style>
